#include "resultui.h"
#include "ui_resultui.h"
#include <QDebug>

ResultUI::ResultUI(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ResultUI)
{
    ui->setupUi(this);
    setAttribute(Qt::WA_DeleteOnClose);//调用close时就调用析构，释放空间
    //    设置固定大小
    setFixedSize(470,720);
    setWindowTitle("CTYYPE");
    //    设置图标
    setWindowIcon(QIcon(":/image/enemy1.png"));
    ui->label->setStyleSheet("QLabel {color:#595959;}");
    ui->label_2->setStyleSheet("QLabel {color:#595959;}");
    ui->label_3->setStyleSheet("QLabel {color:#595959;}");
    ui->totalscore->setStyleSheet("QLabel {color:green;}");
    ui->wrongcount->setStyleSheet("QLabel {color:red;}");
    ui->textEdit->setStyleSheet("QTextEdit {background-color:#595959; border:3px solid #FBF8F3; color:#FBF8F3;}");

    pushBTN =new usualButton(this);
    pushBTN->setText("确认");
    pushBTN->move(175,570);

    connect(pushBTN,&usualButton::clicked,[=](){
        this->close();
    });
}

void ResultUI::paintEvent(QPaintEvent *event)
{
    QPainter resPainter(this);
    resPainter.drawPixmap(0,0,this->width(),this->height(),QPixmap(":/image/resultbg.jpg"));
    //添加图标
    QPixmap pix1;
    pix1.load(":/image/me1.png");
    pix1=pix1.scaled(pix1.width()*0.8,pix1.height()*0.8);
    resPainter.drawPixmap(330,60,pix1);
}

void ResultUI::setPp(int w, int s, QString rw[])
{
    wrongCount=w;
    wrongWords=rw;
    score=s;
    ui->totalscore->setText(QString::number(score));
    ui->wrongcount->setText(QString::number(wrongCount));
    QString TS="";
    for(int i=1;i<=wrongCount;i++)
    {
        TS+=wrongWords[i]+"\n";
    }
    ui->textEdit->setText(TS);
}

ResultUI::~ResultUI()
{
    delete pushBTN;
    delete ui;
}
